#!/opt/anaconda3/bin/python
# -*- coding:utf-8 -*-
'''
@project : meiguo_mall
@author  : leftxxk
#@file   : views.py
#@time   : 2021-06-02 23:09:48
'''

from django.contrib.auth.mixins import AccessMixin
from django.http import JsonResponse


# 用户中心展示使用
# 当没有登陆的时候 return JsonResponse({'code': 400, 'errmsg': 'NONOOOO'})
class LoginRequiredJsonMixin(AccessMixin):
    def dispatch(self, request, *args, **kwargs):
        if not request.user.is_authenticated:
            return JsonResponse({'code': 400, 'errmsg': 'NONOOOO'})
        return super().dispatch(request, *args, **kwargs)
